package web

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"testPaper/common"
	"testPaper/model"
	"testPaper/response"
)

// QueryTag 查询标签
func QueryTag(c *gin.Context) {
	DB := common.GetDB()
	SortId := c.PostForm("sort_id")

	if SortId == "" {
		response.Reponse(c, http.StatusOK, 422, nil, "未知分类ID")
		return
	}
	tag := make([]model.TestPaperTag, 0)
	var total int
	DB.Where("sort_id = ?", SortId).Find(&tag).Count(&total)
	response.Reponse(c, http.StatusOK, 200, gin.H{"data": tag, "total": total}, "获取成功")
	return
}
